package danli;

public class suo {
    /**
     * 双重锁校验机制     *
     */
    private static volatile suo instance=null;

    private suo(){
        System.out.println("学习委员产生了");
    }
    public static synchronized suo getInstance(){
        if (instance == null) {
            instance=new suo();
        }else {
            System.out.println("已经有一个学习委员，不能产生新的学习委员");
        }
        return  instance;
    }
    public static void setInstance(suo instance){
        suo.instance=instance;
    }
    public void getName(){
        System.out.println("我是学习委员:楼啥子");
    }
}
